<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*,
				 com.kylin.module.shop.orm.*,
                 com.kylin.common.util.*,
                 com.kylin.common.paginate.DisplayPage,
				 com.kylin.module.user.orm.*" %>
<%@ include file="/common/include/taglibs.jsp"%>
<%@ include file="/common/include/pageExpires.jsp"%>
<%@ include file="/common/include/dictNames.jsp"%>


<mytag:MyActionMsg />

			<table width="80%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td align="left">
						<bean:message key="service.01" />
					</td>
				</tr>
			</table>
			<br>
			<form action="/module/service/serviceAction.do?CMD=add" method="post"
				name="serviceForm" onSubmit="return checkForm(this)">
				<table width="80%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td colspan="2" class="su01">
							<bean:message key="service.02" />
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="service.03" />

						</td>
						<td>
						<%-- 服务类别下拉菜单 对应字典名 dict_services，参见 /common/include/dictNames.jsp --%>                                    
						<mytag:select name="catService" notEmpty="true" dictName="<%=dict_services%>"/>	
							*
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="service.04" />

						</td>
						<td>
							<input name="contact" type="text" size="20" check="^\S+$"
								warning="<bean:message key="service.05" />">
							*
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="service.06" />
						</td>
						<td>
						<%-- 职位下拉菜单 对应字典名 dict_position，参见 /common/include/dictNames.jsp --%>                                    
						<mytag:select name="position" notEmpty="true" dictName="<%=dict_position%>"/>	
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="base.05" />

						</td>
						<td>
							<input name="phoneCountry" type="text" size="4" check="^\d+$"
								warning="<bean:message key="base.10" />">
							<input name="phoneArea" type="text" size="4" check="^\d+$"
								warning="<bean:message key="base.10" />">
							<input name="phone" type="text" size="20" check="^\d+$"
								warning="<bean:message key="base.10" />">
							<bean:message key="base.08" />*
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="base.06" />
						</td>
						<td>
							<input name="faxCountry" type="text" size="4">
							<input name="faxArea" type="text" size="4">
							<input name="fax" type="text" size="20">
							<bean:message key="base.09" />

						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="base.07" />
						</td>
						<td>
							<input name="email" type="text" size="40"
								check="^\w+@\w+(\.\w+)+(\,\w+@\w+(\.\w+)+)*$"
								warning="<bean:message key="base.20" />">
							*
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="base.16" />
						</td>
						<td>
					<%-- 所有国家下拉菜单 对应字典名 Constants.ALLCOUNTRY --%>  	
					<mytag:national name="country" value="<%= sessionLocale.toString() %>" 
					               notEmpty="true" dictName="<%=Constants.ALLCOUNTRY%>"/>
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="base.21" />
						</td>
						<td>
							<input name="city" type="text" size="20">
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="base.22" />
						</td>
						<td>
							<input name="postcode" type="text" size="20">
						</td>
					</tr>
					<tr class="su03">
						<td align="left">
							<bean:message key="base.23" />

						</td>
						<td>
							<textarea name="content" cols="60" rows="6" check="^\S+$"
								warning="<bean:message key="service.07" />"></textarea>
							*
						</td>
					</tr>
					<tr align="center" valign="bottom">
						<td height="60" colspan="2">
							<input type="submit" name="submit"
								value="<bean:message key="base.24" />">
						</td>
					</tr>
				</table>
			</form>
			<p></p>
<script language="javaScript">
function checkForm(oForm)
{
    var els = oForm.elements;
    for(var i=0;i<els.length;i++)
    {
        if(els[i].check)
        {
            var sReg = els[i].check;
            var sVal = GetValue(els[i]);
            var reg = new RegExp(sReg,"i");

            if(!reg.test(sVal))
            {
                alert(els[i].warning);
                GoBack(els[i])  
                return false;
            }
        }
    }
}

function GetValue(el)
{
    var sType = el.type;
    switch(sType)
    {
        case "text":
        case "hidden":
        case "password":
        case "file":
        case "textarea": return el.value;
        case "checkbox":
        case "radio": return GetValueChoose(el);
        case "select-one":
        case "select-multiple": return GetValueSel(el);
    }
    function GetValueChoose(el)
    {
        var sValue = "";
        var tmpels = document.getElementsByName(el.name);
        for(var i=0;i<tmpels.length;i++)
        {
            if(tmpels[i].checked)
            {
                sValue += "0";
            }
        }
        return sValue;
    }
    function GetValueSel(el)
    {
        var sValue = "";
        for(var i=0;i<el.options.length;i++)
        {
            if(el.options[i].selected && el.options[i].value!="")
            {
                sValue += "0";
            }
        }
        return sValue;
    }
}

function GoBack(el)
{
    var sType = el.type;
    switch(sType)
    {
        case "text":
        case "hidden":
        case "password":
        case "file":
        case "textarea": el.focus();var rng = el.createTextRange(); rng.collapse(false); rng.select();
        case "checkbox":
        case "radio": var els = document.getElementsByName(el.name);els[0].focus();
        case "select-one":
        case "select-multiple":el.focus();
    }
}
function CheckField(Field)
{
        if(Field.check)
        {
            var sReg = Field.check;
            var sVal = GetValue(Field);
            var reg = new RegExp(sReg);
            if(!reg.test(sVal))
            {
                alert(Field.warning);
                GoBack(Field)  
                return false;
            }
        }
  return true;   
}
</script>

